﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using App1AppHandler;

namespace Reborn_WorldServer.App1AppHandler
{
    public class TradeSkillData
    {
        public string skill;
        public decimal level;

        public List<RecipieData> recipies = new List<RecipieData>();

        public string toXml(Character sendingToCharacter)
        {
            string result = "";

            StringWriter stringWriter = new StringWriter();
            XmlTextWriter xmldoc = new XmlTextWriter(stringWriter);

            xmldoc.WriteStartElement("tradeskilldata");

            xmldoc.WriteAttributeString("skill", skill.ToString());
            xmldoc.WriteAttributeString("level", level.ToString());

            foreach (RecipieData rd in recipies)
                xmldoc.WriteRaw(rd.toXml(sendingToCharacter));

            xmldoc.WriteEndElement();
            xmldoc.Flush();

            xmldoc.Close();

            stringWriter.Flush();

            result = stringWriter.ToString();

            return result;
        }
    }
}
